package com.Stream;

import java.util.ArrayList;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamDemo04 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("zhangsan,23");
        list.add("lisi,22");
        list.add("wangwu,25");
        Stream<String> ss = list.stream();
        Map<String, Integer> map = ss.filter(
                (String s) -> {
                    String[] split = s.split(",");
                    int ad = Integer.parseInt(split[1]);
                    return ad >= 23;
                }
        ).collect(Collectors.toMap(
                (String s) -> {
                    return s.split(",")[0];
                },
                (String s) -> {
                    return Integer.parseInt(s.split(",")[1]);

                }
                )
        );
        System.out.println(map);

    }
}
